package me.shurufa.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;

import me.shurufa.R;
import me.shurufa.fragments.ThirdPartyLoginFragment;
import me.shurufa.utils.StatusBarCompat;

/**
 * Create by andy (https://github.com/andyxialm)
 * Create time: 16/5/9 15:11
 * Description :
 */
public class ThirdPartyActivity extends BaseActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        activity_layout_res = R.layout.activity_third_party_login;
        super.onCreate(savedInstanceState);
        initFragment();
    }

    private void initFragment() {
        String loginType = getIntent().getStringExtra("loginType");
        String openid = getIntent().getStringExtra("openid");
        String accessToken = getIntent().getStringExtra("accessToken");
        String unionid = getIntent().getStringExtra("unionid");
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, ThirdPartyLoginFragment.newInstance(loginType, openid, accessToken, unionid));
        fragmentTransaction.commit();
    }

    @Override
    public void initStatusBar() {
        StatusBarCompat.setTranslucent(this, R.color.red_new);
    }

    public static void initArguments(Intent in, String loginType, String openid, String accessToken, String unionid) {
        in.putExtra("loginType", loginType);
        in.putExtra("openid", openid);
        in.putExtra("accessToken", accessToken);
        in.putExtra("unionid", unionid);
    }
}
